package dao.impl;

import dao.EnterpriseDao;
import pojo.Enterprise;
import util.DBHelper;

import java.util.ArrayList;

public class EnterpriseDaoimpl implements EnterpriseDao {
    DBHelper db=new DBHelper();
    @Override
    public int insertEnterprise(Enterprise enterprise) {
        String sql="insert into enterprise values(null,?,?,?,?,?,?,?)";
        return db.updateTable(sql,enterprise.getName(),
                enterprise.getSocial_uniform_code(),enterprise.getEmail(),
                enterprise.getPhone(),enterprise.getAddress(),enterprise.getScale(),
                enterprise.getFax());
    }

    @Override
    public ArrayList selectEnterprise(Enterprise enterprise) {
        return null;
    }

    @Override
    public Enterprise selectEnterpriseById(Enterprise enterprise) {
        String sql="select * from enterprise where id=?";
        return (Enterprise)db.query(sql,Enterprise.class,enterprise.getId()).get(0);
    }

}
